﻿using InsertionSort;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace InsertionSortTests
{
    [TestClass()]
    public class ProgramTest
    {
        [TestMethod()]
        public void ProgramConstructorTest()
        {
            Program target = new Program();
        }

        public void InsertionSortTestHelper<T>()
            where T : IComparable<T>
        {
            T[] array = null; // TODO: Initialize to an appropriate value
            Program.InsertionSort<T>(array);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        [TestMethod()]
        public void InsertionSortIntegerTest()
        {
            int[] intArray = { 9, 7, 5, 3, 1, 2, 4, 6, 8, 5, 4, 5 };
            int[] sortedArray = new int[intArray.Length];
            Array.Copy(intArray, sortedArray, intArray.Length);
            Program.InsertionSort(intArray);
            Array.Sort(sortedArray);
            Assert.AreEqual(intArray.Length, sortedArray.Length);
            for (int i = 0; i < intArray.Length; i++)
            {
                Assert.AreEqual(intArray[i], sortedArray[i]);
            }
        }

        [TestMethod()]
        public void InsertionSortDoubleTest()
        {
            double[] intArray = { 9.2, 7.3, 5.1, 3.0, 1.3, 2.6, 4.88, 6.21, 8.56, 5.2, 4.4, 5.1 };
            double[] sortedArray = new double[intArray.Length];
            Array.Copy(intArray, sortedArray, intArray.Length);
            Program.InsertionSort(intArray);
            Array.Sort(sortedArray);
            Assert.AreEqual(intArray.Length, sortedArray.Length);
            for (int i = 0; i < intArray.Length; i++)
            {
                Assert.AreEqual(intArray[i], sortedArray[i]);
            }
        }

        [TestMethod()]
        public void MainTest()
        {
            Program.Main();
        }
    }
}
